import Observe from './Observe.js'

class Vue {
  constructor(options) {
    this.$el = options.el
    this.$data = options.data || {}
    this.options = options

    new Observe(this.$data)

    this.proxyData()
  }
  //使用Vue实例访问时，通过代理拦截，使其操作this.$data
  proxyData() {
    for (const [key, value] of Object.entries(this.$data)) {
      Object.defineProperty(this, key, {
        get() {
          return this.$data[key]
        },
        set(newValue) {
          this.$data[key] = newValue
        },
      })
    }
  }
}
export default Vue
